//  $(function () {
//          $.ajax({
//                 headers: {
//                     'Content-Type': 'Access-Control-Allow-Origin'
//                 },
//                 contentType: "application/x-www-form-urlencoded",
//                 type: "get",
//                 url: 'http://rap2api.taobao.org/app/mock/293215/user/findAll',

//                 success: function (res) {
//                     console.log(res)
//                 }
//             })
// }) 

const app = new Vue({
    el: '#app',
    data() {
        return {
            namelist: [],
            imglist: [],
            name: '你好，排行榜',
            isShow: false,
        }

    },

    computed: {
        getTitleData() {
            // $.ajax({
            //     headers: {
            //         'Content-Type': 'Access-Control-Allow-Origin'
            //     },
            //     contentType: "application/x-www-form-urlencoded",
            //     type: "get",
            //     url: 'http://rap2api.taobao.org/app/mock/293215/user/findAll',

            //     success: function (res) {
            //         console.log(res);
            //         this.imglist = res
            //     }
            // })

            axios
                .get('http://localhost:8081/selectSalesList')
                .then((res) => {
                    console.log(res);
                    this.namelist = res.data;
                    console.log(res.data);
                })
                .catch(function (error) {
                    if (error.response) {
                        console.log(error);
                    } else if (error.request) {
                        console.log(error.request);
                    } else {
                        console.log(error.request);
                    }
                    console.log(error.config);
                });
        },
    },

    methods: {
        /*----------------
         *  获取测试数据 
         * 获取类目热销榜的标题数组 
         * 
         */     
        getData() {
            this.$nextTick(function() {
                 axios
                .get('http://localhost:8081/selectSalesList')
                .then((res) => {
                    console.log(res);
                    this.namelist = res.data;
                    console.log(res.data);
                    this.isShow = true;
                })
                .catch(function (error) {
                    if (error.response) {
                        console.log(error);
                    } else if (error.request) {
                        console.log(error.request);
                    } else {
                        console.log(error.request);
                    }
                    console.log(error.config);
                });
            })
           
        },

    },

    created: function () {
        this.$nextTick(() => {
            this.getData();
        })
        // this.getData()
        // this.getTitleData()
        // console.log(this.namelist)
    },
})